package cn.com.jcoo.mp.controller;

import cn.com.jcoo.mp.entity.model.SysMessage;
import cn.com.jcoo.mp.service.ISysMessageService;
import cn.com.jcoo.mp.service.impl.SysMessageServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 系统消息主体表 前端控制器
 * </p>
 *
 * @author jinty
 * @since 2024-01-22
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/mp/sys-message")
@RequiredArgsConstructor
public class SysMessageController {

	// @Autowired
	//// @Qualifier("sysMessageService")
	// private ISysMessageService sysMessageService;
	//
	// @Autowired
	//// @Qualifier("slaveSysMessageService")
	// private ISysMessageService slaveSysMessageService;

	private final ISysMessageService sysMessageService;

	private final ISysMessageService slaveSysMessageService;

	@GetMapping("/page")
	public Page<SysMessage> page(@NotBlank(message = "请求参数错误") String ds) {
		return switch (ds) {
		case "master" -> sysMessageService.page(Page.of(0, -1));
		case "slave" -> slaveSysMessageService.page(Page.of(0, -1));
		default -> null;
		};

	}

}
